package com.cqu.hospitalsystem.controller;

import com.alibaba.fastjson.JSONObject;
import com.cqu.hospitalsystem.Vo.preCheck;
import com.cqu.hospitalsystem.service.FileService;
import com.cqu.hospitalsystem.utils.result.DataResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("file")
@Tag(name = "FileController", description = "文件传输")
public class FileController {
    @Resource
    private FileService fileService;

    @GetMapping("img")
    @Operation(summary = "获取图片文件", description = "根据图片地址获得二进制图片")
    public ResponseEntity<byte[]> getImg(@RequestParam @Parameter(description = "地址") String img_addr){
        return this.fileService.getImg(img_addr);
    }

    @GetMapping("imgBase64")
    @Operation(summary = "获取图片文件的base64格式", description = "根据图片地址获得二进制图片")
    public ResponseEntity<String> getImgBase64(@RequestParam @Parameter(description = "地址") String img_addr){
        return this.fileService.getImgBase64(img_addr);
    }
}
